//
//  WeAuctionMapCell.m
//  WeGalaxy
//
//  Created by Zheng on 2017/7/11.
//  Copyright © 2017年 Zheng. All rights reserved.
//

#import "WeAuctionMapCell.h"

@implementation WeAuctionMapCell

#pragma mark - 初始化方法

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        
        self.backgroundColor = [UIColor whiteColor];
        self.layer.borderWidth = 1;
        self.layer.borderColor = [[UIColor lightGrayColor] CGColor];
        
        [self subviewsInContentView];
    }
    return self;
}

#pragma mark - 子视图
- (UILabel *)titleLbl {
    if (!_titleLbl) {
        _titleLbl = [UILabel new];
        _titleLbl.text = @"标题";
        _titleLbl.font = kCX_FONT(12);
    }
    return _titleLbl;
}

- (UILabel *)priceLbl {
    if (!_priceLbl) {
        _priceLbl = [UILabel new];
        _priceLbl.text = @"¥ 900";
        _priceLbl.textColor = kRGB_COLOR(245, 67, 55, 1);
        _priceLbl.font = kCX_FONT(13);
        _priceLbl.textAlignment = NSTextAlignmentRight;
    }
    return _priceLbl;
}

- (UILabel *)describeLbl {
    if (!_describeLbl) {
        _describeLbl = [UILabel new];
        _describeLbl.text = @"描述";
        _describeLbl.textColor = [UIColor grayColor];
        _describeLbl.font = kCX_FONT(11);

    }
    return _describeLbl;
}

- (UIView *)grayBgView {
    if (!_grayBgView) {
        _grayBgView = [UIView new];
        _grayBgView.backgroundColor = kRGB_COLOR(244, 244, 244, 1);
    }
    return _grayBgView;
}

- (UIImageView *)iconImgv {
    if (!_iconImgv) {
        _iconImgv = [UIImageView new];
        kCX_RADIUS(_iconImgv, 20, 1);
        _iconImgv.backgroundColor = [UIColor redColor];
        _iconImgv.layer.borderColor = [[UIColor grayColor] CGColor];
        _iconImgv.layer.borderWidth = 1;
        _iconImgv.layer.masksToBounds = YES;
    }
    return _iconImgv;
}

- (UILabel *)nameLbl {
    if (!_nameLbl) {
        _nameLbl = [UILabel new];
        _nameLbl.text = [NSString stringWithFormat:@"My---%d",arc4random()%10];
        _nameLbl.font = kCX_FONT(11);
    }
    return _nameLbl;
}


- (void)subviewsInContentView {
    
    [self.contentView addSubview:self.grayBgView];
    [self.contentView addSubview:self.titleLbl];
    [self.contentView addSubview:self.describeLbl];
    [self.contentView addSubview:self.priceLbl];
    [self.contentView addSubview:self.iconImgv];
    [self.contentView addSubview:self.nameLbl];
    
    [_grayBgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.bottom.right.equalTo(self);
        make.height.mas_equalTo(65);
    }];
    
    [_titleLbl mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(35);
        make.top.mas_equalTo(15);
    }];
    
    [_describeLbl mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_titleLbl);
        make.top.equalTo(_titleLbl.mas_bottom).offset(10);
    }];
    
    [_priceLbl mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-25);
        make.top.mas_equalTo(20);
    }];
    
    [_iconImgv mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.height.mas_equalTo(40);
        make.bottom.mas_equalTo(-10);
        make.left.mas_equalTo(15);
    }];
    
    [_nameLbl mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_iconImgv.mas_right).offset(12);
        make.centerY.equalTo(_iconImgv);
    }];
    
}


@end
